<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>修改我的信息</title>
<!-- Bootstrap -->
<link href="http://www.udppvr.cn:80/static/bootstrap/css/bootstrap.min.css"
	rel="stylesheet">
<link href="../../../../statics/shuafen/css/profile_style.css" rel="stylesheet">
<link href="../../../../statics/shuafen/css/response.css" rel="stylesheet">
<link href="../../../../statics/shuafen/css/bootstrapValidator.css"
	rel="stylesheet">
<link href="../../../../statics/shuafen/css/default.css"
	rel="stylesheet">
<link href="../../../../statics/shuafen/css/fileinput.css"
	rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
      <script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
    <![endif]-->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="../../../../statics/shuafen/js/lib/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../../../../statics/shuafen/js/lib/bootstrap.min.js"></script>
<script src="../../../../statics/shuafen/js/lib/bootstrapValidator.min.js"></script>
<script src="../../../../statics/shuafen/js/lib/fileinput.min.js"></script>
<script src="../../../../statics/shuafen/js/lib/fileinput_locale_zh.js"></script>
<script src="../../../../statics/shuafen/js/lib/style.js"></script>
<script type="text/javascript">
	//初始化表单验证
	$(function (){
		$('#fm').bootstrapValidator({
			live: 'disabled',
			message: '输入有误',
			feedbackIcons: {
				valid: 'glyphicon glyphicon-ok',
				invalid: 'glyphicon glyphicon-remove',
				validating: 'glyphicon glyphicon-refresh'
			},
			fields : {
				"nickname" : {
					validators : {
						notEmpty : {
							message : '<span style="font-size:1.2em;">昵称不能为空！</span>'
						}
					}
				},
				"province":{
					validators: {
						notEmpty: {
							message: '<span style="font-size:1.2em;">请选择所在省份！</span>'
						}
					}
				},
				"city":{
					validators: {
						notEmpty: {
							message: '<span style="font-size:1.2em;">请选择所在城市！</span>'
						}
					}
				},
				"industry_one":{
					validators: {
						notEmpty: {
							message: '<span style="font-size:1.2em;">请选择一级行业！</span>'
						}
					}
				},

			}
		});
	});
	//当页面加载完成后，初始化一级行业列表
	var option = '<option value="">请选择行业</option>';
	$(function (){
		setup();
		preselect('<?php echo $member["province"]?>','<?php echo $member["city"]?>');

		$.ajax({
			url : 'index.php?m=shuafen&c=web&a=getIndustry',
			method : 'get',
			success : function (rs){
				$("#level_1").append(option);
				var select = '';
				for (var i = 0; i < rs.length; i ++) {
					var select = '';
					if(rs[i].id==<?php echo $member['industry_one']?>){
						select = 'selected';
					}
					$("#level_1").append('<option '+select+' value="'+rs[i].id+'">'+rs[i].industry_name+'</option>');
				}
				initIndustry(<?php echo $member['industry_one']?>,'level_2',<?php echo $member['industry_two']?>);
			},
			dataType : 'json'
		});
		$("#industry").on("change",'#level_1',function (){
			initIndustry($(this).val(),'level_2',false);
		});
		$("#industry").on("change",'#level_2',function (){
			initIndustry($(this).val(),'level_3',false);
		});
	});
	function initIndustry(pid,level,value){
		if(!pid) return;
		$("#"+level).parent().remove();
		$("#level_3").parent().remove();
		var industry_type_name = level=='level_2'?'二级行业':'三级行业';
		var industry_id_name = level=='level_2'?'industry_two':'industry_three';

		$.ajax({
			url : 'index.php?m=shuafen&c=web&a=getIndustry&pid='+pid,
			method : 'get',
			success : function (rs){
				if(!rs.length){
					return;
				}
				var str = '<div class="form-group input-group">'+
						'<span class="input-group-addon">'+industry_type_name+'</span>'+
						'<select id="'+level+'" class=" form-control" name="'+industry_id_name+'"></select>'+
						'</div>';
				$("#industry").append(str);
				$("#"+level).append(option);
				for (var i = 0; i < rs.length; i ++) {
					var select = '';
					if(value && rs[i].id==value){
						select = 'selected';
					}
					$("#"+level).append('<option '+select+' value="'+rs[i].id+'">'+rs[i].industry_name+'</option>');
				}
				$('#fm').bootstrapValidator('addField', industry_id_name, {
					validators: {
						notEmpty: {
							message: '<span style="font-size:1.2em;">请选择'+industry_type_name+'！</span>'
						}
					}
				});
				if(industry_id_name=='industry_two' && value){
					initIndustry(<?php echo $member['industry_two']?>,'level_3',<?php echo $member['industry_three']?>);

				}
			},
			dataType : 'json'
		});
	}

</script>
</head>
<body style="margin:5px;">
	<div class="prolist">
		<form id="fm" method="post" action="index.php?m=shuafen&c=web&a=updateMyInfo">
			<div class="form-group input-group">
				<span class="input-group-addon">昵称</span> <input type="text"
					id="nickName" name="nickname" class="form-control" value="<?php echo $member['nickname'];?>"
					placeholder="请输入昵称" />
			</div>
			<div class="form-group input-group">
				<span class="input-group-addon">手机</span> <input type="text" readonly="readonly"
					id="telephone" name="username" class="form-control" value="<?php echo $member['username'];?>"
					placeholder="绑定微信手机号" />
			</div>
			<div class="form-group input-group">
				<span class="input-group-addon">性别</span>
				<div class="form-control">
					<label class="checkbox-inline"> <input type="radio"
						name="sex" id="gender_man" value="0" <?php if(!$member['sex']){echo 'checked';}?> >男
					</label> <label class="checkbox-inline"> <input type="radio"
						name="sex" id="gender_woman" value="1" <?php if($member['sex']){echo 'checked';}?> > 女
					</label>
				</div>
			</div>
			<div class="form-group input-group">
				<span class="input-group-addon">省份</span>
				<select id="s1" class="form-control" name="province"></select>

			</div>
			<div class="form-group input-group">
				<span class="input-group-addon">城市</span> <select id="s2"
																  name="city" class="form-control">
			</select>
			</div>
			<div id="industry">
				<div class="form-group input-group">
					<span class="input-group-addon">一级行业</span>
					<select id="level_1" name="industry_one" class=" form-control">
					</select>
				</div>
			</div>
			<div class="form-group input-group">
				<span class="input-group-addon">头像</span> 
				<select class="form-control" name="img" onchange="javascript:document.getElementById('imgBox').src='{SHUAFEN_STATICS_PATH}/images/avatar/'+this.value">
					<?php for($i=10;$i<=20;$i++){?>
					<?php
						$sel = $i.'.jpg'==$member['img'] ? 'selected':'';
					?>
					<option <?php echo $sel;?> value="<?php echo $i;?>.jpg">photo_<?php echo $i;?></option>
					<?php }?>
				</select>
				<img src="{SHUAFEN_STATICS_PATH}/images/avatar/<?php echo $member['img']?>" id="imgBox"/>
			</div>
			<div style="color:red;font-size:14px;text-align: center;">
				<?php echo $message ?>
			</div>
			<input name="dosubmit" type="submit" class="btn btn-primary btn-lg btn-block"
				value="修改" />
		</form>
		<div class="clearfix"></div>
	</div>
	<!--prolist/-->
	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">修改我的信息</h4>
				</div>
				<div class="modal-body" id="modelText"></div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>
	<script src="<?php echo JS_PATH?>city.js"></script>
</body>
</html>